package org.quipu.dto;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class AccountDto extends UniqueTitledDto {

    private Long bookId;
    private Date creationDate = new Date();
    private DebtDto debt;
    private HashMap<Long, Double> initBalances = new HashMap<Long, Double>();

    public Long getBookId() {
        return bookId;
    }

    public void setBookId(Long bookId) {
        this.bookId = bookId;
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public DebtDto getDebt() {
        return debt;
    }

    public void setDebt(DebtDto debt) {
        this.debt = debt;
    }

    public boolean isDebt() {
        return (debt != null);
    }

    public Double getInitialBallance(Long currencyId) {
        Double sum = initBalances.get(currencyId);
        if(sum == null) {
            sum = 0.0;
        }
        return sum;
    }

    public void addInitialBallance(Long currencyId, Double sum) {
        initBalances.put(currencyId, sum);
    }

    public void removeInitialBallance(Long currencyId) {
        initBalances.remove(currencyId);
    }

    public void clearInitialBallance() {
        initBalances.clear();
    }

    public Map<Long, Double> getInitialBallances() {
        return initBalances;
    }
}
